package business.global.pk.ddz.cardtype.type;

import business.ddz.c2s.cclass.DDZ_define;
import business.global.pk.alg.params.BaseOpCard;
import business.global.pk.alg.params.BasePKParameter;
import business.global.pk.alg.type.Type_Straight;
import business.global.pk.ddz.cardtype.util.DDZALGUtil;
import jsproto.c2s.cclass.pk.BasePockerLogic;

import java.util.ArrayList;

/**
 * 顺子 straight（34567）
 */
public class DDZStraight extends Type_Straight<DDZALGUtil> {

    @Override
    public BaseOpCard getCardList(BasePKParameter parameter) {
        int previousOpType = parameter.previousOpType;
        ArrayList<Integer> previousCardList = parameter.previousCardList;
        //压开局
        if (previousOpType == DDZ_define.DDZ_CARD_TYPE.DDZ_CARD_TYPE_NOMARL.value()) {
            for (int i = 11; i >= 5; i--) {
                parameter.lastTripleNum = i;
                parameter.targetType = DDZ_define.DDZ_CARD_TYPE.DDZ_CARD_TYPE_SHUNZI.value();
                BaseOpCard straight = getBasePKALGUtil().getStraight(parameter);
                if (straight != null) {
                    return straight;
                }
            }
        }
        //压顺子
        if (previousOpType == DDZ_define.DDZ_CARD_TYPE.DDZ_CARD_TYPE_SHUNZI.value()) {
            previousCardList.sort(BasePockerLogic.sorterBigToSmallHaveTrump);
            parameter.targetType = DDZ_define.DDZ_CARD_TYPE.DDZ_CARD_TYPE_SHUNZI.value();
            return getBasePKALGUtil().getStraight(parameter);
        }
        return null;
    }

    @Override
    public BaseOpCard checkCardList(BasePKParameter parameter) {
        return getBasePKALGUtil().checkStraight(parameter);
    }

    @Override
    public DDZALGUtil getBasePKALGUtil() {
        return DDZALGUtil.getInstance();
    }
}
